var href = window.location.href;
activeMenu();
$('.reset-button').click(function(){
        $("input[type='text'],textarea").val('');
});

$('#NodeBookingsForm').validate();
//Comment ajax
$('.form-comments').submit(function(e){
        var content = $('.comment-content').val();
        var fullname = $('.comment-fullname').val();
        var email = $('.comment-email').val();
        var capcha = $('.comment-capcha').val();
        if(content==''){
            alert('Vui lòng nhập ý kiến của bạn !');
            $('.comment-content').focus();
            return false;
        }
        if(fullname==''){
            alert('Vui lòng nhập họ tên !');
            $('.comment-fullname').focus();
            return false;
        }
        if(email==''){
            alert('Vui lòng nhập email !');
            $('.comment-email').focus();
            return false;
        }
        if(validateEmail(email)==false){
            alert('Email không đúng định dạng !');
            $('.comment-email').focus();
            return false;
        }

        if(capcha==''){
            alert('Vui lòng nhập mã code !');
            $('.comment-capcha').focus();
            return false;
        }
        var formObj = $(this);
        var formURL = formObj.attr("action");
        var formData = new FormData(this);
        $.ajax({
                url: formURL,
                type: 'POST',
                data:  formData,
                mimeType:"multipart/form-data",
                contentType: false,
                dataType: 'json',
                cache: false,
                processData:false,
                success: function(data, textStatus, jqXHR)
                {
                    alert(data.msg);
                    if(data.code==200) $("input[type='text'],textarea").val('');
                }
        });
        return false;
});
//End

//Valid Email
function validateEmail($email) {
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
    if (!emailReg.test($email)) {
        return false;
    } else {
        return true;
    }
}
function activeMenu(){
    if ((href.indexOf('/gioi-thieu') != -1)||(href.indexOf('/goc-bao-chi-va-hoat-dong-usis') != -1)||(href.indexOf('/video-usis') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_1').addClass("active");
    }
    if ((href.indexOf('/dich-vu') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_2').addClass("active");
    }
    if ((href.indexOf('/du-an') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_3').addClass("active");
    }    
    if ((href.indexOf('/tu-van') != -1)||(href.indexOf('/dat-cau-hoi') != -1)||(href.indexOf('/cau-hoi-thuong-gap') != -1)||(href.indexOf('/khach-hang-chia-se') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_4').addClass("active");
    }
    if ((href.indexOf('/cuoc-song-tai-my') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_5').addClass("active");
    }
    if ((href.indexOf('/tin-tuc') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_6').addClass("active");
    }
    if ((href.indexOf('/lien-he') != -1)) {
        $('#bs-example-navbar-collapse-1 ul li').find('active').removeClass('active');
        $('#bs-example-navbar-collapse-1 ul li.item_7').addClass("active");
    }
}